{***************************************************************************}
{                                                                           }
{           UIAuto4D                                              }
{                                                                           }
{           Copyright 2015 JHC Systems Limited                              }
{                                                                           }
{***************************************************************************}
{                                                                           }
{  Licensed under the Apache License, Version 2.0 (the "License");          }
{  you may not use this file except in compliance with the License.         }
{  You may obtain a copy of the License at                                  }
{                                                                           }
{      http://www.apache.org/licenses/LICENSE-2.0                           }
{                                                                           }
{  Unless required by applicable law or agreed to in writing, software      }
{  distributed under the License is distributed on an "AS IS" BASIS,        }
{  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{  See the License for the specific language governing permissions and      }
{  limitations under the License.                                           }
{                                                                           }
{***************************************************************************}
unit UIAuto4D.Clipboard;

interface

type
  TAutomationClipboard = class
  strict private

  public
    /// <summary>
    ///  Gets the clipboard contents as text (if it was a grid)
    /// </summary>
    class function GridText : TArray<String>;

    /// <summary>
    ///  Gets the number of rows in the clipboard, assuming it is a 'table'
    /// </summary>
    class function RowCount : integer;
  end;

implementation

uses
  sysutils,
  clipbrd;

{ TAutomationClipboard }

class function TAutomationClipboard.GridText: TArray<String>;
var
  Lines : TArray<String>;
begin
  Lines := clipboard.AsText.Split([#$D]);
  result := Lines;
end;

class function TAutomationClipboard.RowCount: integer;
var
  Lines : TArray<String>;
begin
  Lines := clipboard.AsText.Split([#$D]);
  result := length(Lines);
end;

(*
  for line in lines do
  begin
    if line[1] = #$A then
      f := copy(line, 2, length(line) -1)
    else
      f := line;

    fields := f.Split([#9]);
    for field in fields do
    begin
      X := field;
    end;
  end;
*)

end.
